﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HTDAL.HTSPC_DBDataSetTableAdapters;

namespace HTspcAppProject
{
    public partial class FormWarInfo : Form
    {
        string DevNm;
        public bool resetTag = false;
        public FormWarInfo(int device_num, string devNm)
        {
            InitializeComponent();
            label_title.Text = devNm + "  报警内容";
            DevNm = devNm;
        }

        private void FormWarInfo_Load(object sender, EventArgs e)
        {
            dgvRefresh();
        }

        private void dgvRefresh()
        {
            ht_WarLogTableAdapter warTa = new ht_WarLogTableAdapter();
            DataTable erroDt = warTa.GetDataBySt(DevNm, "0");
            dgvWarInfo.AutoGenerateColumns = false;
            dgvWarInfo.DataSource = erroDt;
            KeyidColumn.DataPropertyName = "keyid";
            DtColumn.DataPropertyName = "dt";
            InfoColumn.DataPropertyName = "info";
            ReasonColumn.DataPropertyName = "reason";
            SolColumn.DataPropertyName = "sol";
            StColumn.DataPropertyName = "st";
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            try
            {
                ht_WarLogTableAdapter warTa = new ht_WarLogTableAdapter();
                warTa.UpdateSt("1", DevNm, "0");
                resetTag = true;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;

            }
            catch(Exception ex)
            {
                MessageBox.Show("数据更新中发生异常，请检查服务器连接是否正常。异常提示：\n" + ex.Message,
                    "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
